
package com.xin.di.uav.applet.mapper;

import com.xin.di.uav.user.order.po.PaymentBillPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface PaymentBillMapper {


    @Select({"<script>",
            "select count(1) \n" +
                    "from payment_bill where 1=1 " +
                    "<if test='startTime != null '>" +
                    " AND trade_time &gt; #{startTime} AND trade_time &lt; #{endTime} </if>",
            "    <if test='orderNo != null and orderNo !=\"\"  '> and  order_no = #{orderNo}</if>",
            "</script>"})
    int count(@Param("orderNo") String orderNo, @Param("startTime") Date startTime, @Param("endTime") Date endTime);


    @Select({"<script>",
            "select id, order_no, channel_trade_no, type, amount, currency, trade_time, payment_channel, remark,\n" +
                    "                          created_at, updated_at \n" +
                    "from payment_bill where 1=1 " +
                    "<if test='startTime != null '>" +
                    " AND trade_time &gt; #{startTime} AND trade_time &lt; #{endTime} </if>",
            "    <if test='orderNo != null and orderNo !=\"\"  '> and  order_no = #{orderNo}</if>",
            "order by created_at desc   limit #{offset},#{pageSize} ",
            "</script>"})
    List<PaymentBillPO> selectList(@Param("offset") int offset, @Param("pageSize") int pageSize,
                                   @Param("orderNo") String orderNo, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
}
